package com.cnzz.site1255174697.utils;

import android.app.Activity;
import android.os.Build;
import android.view.View;
import android.widget.LinearLayout;

import com.cnzz.site1255174697.R;
import com.cqyanyu.yanyu.utils.SystemBarTintManager;

/**
 * 设置单一页面的状态栏颜色
 */
public class SystemBarUtils {

    /**
     * 设置单一页面的状态栏颜色
     *
     * @param activity
     * @param rootView
     */
    public static void setSystemBarColor(Activity activity, View rootView) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            SystemBarTintManager systemBarTintManager = new SystemBarTintManager(activity);
            LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) rootView.findViewById(R.id.statusBar).getLayoutParams();
            layoutParams.height = systemBarTintManager.getConfig().getStatusBarHeight();
            rootView.findViewById(R.id.statusBar).setLayoutParams(layoutParams);
        }
    }
}
